
//
//  NSMCacheManager.m
//  NSMKit
//
//  Created by nsm on 2019/5/30.
//  Copyright © 2019 nani. All rights reserved.
//

#import "NSMCacheManager.h"

static NSString * const kSMSCache       = @"cache_sms";
static NSString * const kSearchCache    = @"cache_search";
static NSString * const kCSCache        = @"cache_city_selector";

@interface NSMCacheManager ()
@property (nonatomic, strong) YYCache *smsCache;
@property (nonatomic, strong) YYCache *searchCache;
@property (nonatomic, strong) YYCache *csCache;
@end

@implementation NSMCacheManager

+ (instancetype)sharedInstance {
    static NSMCacheManager *instance;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [self new];
    });
    return instance;
}

- (YYCache *)cacheWithName:(NSString *)name {
    return [YYCache cacheWithName:name];
}

#pragma mark - setter/getter
- (YYCache *)smsCache {
    if (!_smsCache) {
        _smsCache = [YYCache cacheWithName:kSMSCache];
    }
    return _smsCache;
}

- (YYCache *)searchCache {
    if (!_searchCache) {
        _searchCache = [YYCache cacheWithName:kSearchCache];
    }
    return _searchCache;
}

- (YYCache *)csCache {
    if (!_csCache) {
        _csCache = [YYCache cacheWithName:kCSCache];
    }
    return _csCache;
}

@end
